package com.zn.test;

import java.util.Scanner;

/**
 * @author Li
 * @Date 2023/4/19 11:47
 */
public class Game {
    public static void main(String[] args) {
        method();
     while(true){
         Scanner scanner = new Scanner(System.in);
         System.out.println("是否继续（y/n）");
         String num3 = scanner.next();
         if (num3.equals("y")){
             System.out.println("继续游戏！");
             method();
         }else if (num3.equals("n")){
             System.out.println("退出游戏！");
             System.exit(0);
             scanner.close();
         }else {
             System.out.println("输入无效，请重新输入:");
         }

     }
    }

 public static void method(){
     System.out.println("请选择:");
     System.out.println("1:石头");
     System.out.println("2:剪刀");
     System.out.println("3:布");
     int num1 = getString("请一号选择:");
     int num2 = getString("请二号选择:");
     if (num1==num2){
         System.out.println("平局");
     }else if (num1==1&num2==2 || num1==2&num2==3 || num1==3&num2==1){
         System.out.println("一号赢了");
     }else {
         System.out.println("二号赢了");
     }
 }
    public static int getString(String str) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(str);
        return scanner.nextInt();
    }

}
